package com.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.domain.ModelName;
import com.domain.Role;
import com.domain.User;

@Repository
public class ModelNameDao extends BaseDao{
	@SuppressWarnings("unchecked")
	public List<ModelName> getAllModelNames(){
		try {
			return sqlMapClient.queryForList("selectAllNames");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void saveModelName(ModelName modelName){
		try {
			sqlMapClient.insert("saveModelName",modelName);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public int checkExist(ModelName modelName){
		try {
			return (Integer)sqlMapClient.queryForObject("checkExist",modelName);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return 0 ;
	}
	public void updateModelName(String newName,String oldName){
		String sql="UPDATE TBL_MODEL_NAME SET MODEL_NAME=? WHERE MODEL_NAME=?";
		jdbcTemplate.update(sql,new Object[]{newName,oldName});
	}
	public void delModelName(ModelName modelName){
		try {
			sqlMapClient.delete("delModelName",modelName);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
